#include<bits/stdc++.h>

using namespace std;

int main()
{
    stack<char> C;
    string ss;
    string s = ""; 
    while(true)
    {
        getline(cin, ss);
        if(ss == ".")
            break;
        for(int i = 0; i < ss.length(); i++)
        {
            if(ss[i] == '['|| ss[i] == '{'||ss[i] == '('||ss[i] == ']'||ss[i] == '}'||ss[i] == ')')
                s += ss[i];
            else if(ss[i] == '/' && ss[i+1] == '*')
            {
                s += '<';
                i++;
            }
            else if(ss[i] == '*' && ss[i+1] == '/')
            {
                s += '>';
                i++;
            }
        }
    }
    for(int i = 0; i < s.length() ; i++)
    {
        if(s[i] == '<'||s[i] == '{'||s[i] == '('||s[i] == '[')
            C.push(s[i]);
        else if(C.empty())
        {
            if(s[i] == '}'||s[i] == ')'||s[i] == ']')
            {
                cout << "NO" << endl;
                cout << "?-" << s[i] << endl;
                return 0;
            }
            else if(s[i] == '>')
            {
                cout << "NO" << endl;
                cout << "?-*/" << endl;
                return 0;
            }
        }
        else if(C.top() == '<')
        {
            if(s[i] == '>')
                C.pop();
            else
            {
                cout << "NO" << endl;
                cout << "/*-?" << endl;
                return 0;
            }
        }
        else if(C.top() == '{')
        {
            if(s[i] == '}')
                C.pop();
            else
            {
                cout << "NO" << endl;
                cout << C.top() << "-?" << endl;
                return 0;
            }
        }
        else if(C.top() == '(')
        {
            if(s[i] == ')')
                C.pop();
            else
            {
                cout << "NO" << endl;
                cout << C.top() << "-?" << endl;
                return 0;
            }
        }
        else if(C.top() == '[')
        {
            if(s[i] == ']')
                C.pop();
            else
            {
                cout << "NO" << endl;
                cout << C.top() << "-?" << endl;
                return 0;
            }
        }
    }
    if(!C.empty())
    {
        if(C.top() == '<')
        {
            cout << "NO" << endl;
            cout << "/*-?" << endl;
        }
        else
        {
            cout << "NO" << endl;
            cout << C.top() << "-?" << endl;
        }
    }
    else
        cout << "YES" << endl;
    return 0;
}

